<?php
//header("Cache-Control: no-store"); 
//header("Expires: " .  date("r"));
//ini_set( "display_errors", 0);
 
include_once 'include.inc';



$report_type=$_GET['report_type'];
$type=$_GET['type'];
$form=$_GET['form'];


if (isset($_POST['form'])) $action = 'processform';
else $action = $_GET['action'];

if(!is_string($action))
        $action= '';
$view = '';
$viewRequest = array();


switch ($action){
case 'update':
        
        $view = 'update';
        break;


case 'reset':
        DBUnlock();
        break;


case 'report': 
        $view = 'report';
        $viewRequest['report_type'] = $report_type;
        break;  


case 'viewform':
        $view = 'showForm';
        $viewRequest['type'] = $type;
        $viewRequest['form'] = $form;
        break;


case 'processform':
	
	switch ($_POST['type']){
		
		case 'proxy':
			$viewRequest['form'] =$_POST['form'];
			$viewRequest['type']="proxy";
	        $viewRequest['ip']=$_POST['ip'];
	        $viewRequest['domain']=$_POST['domain'];
	        $viewRequest['date_start']=$_POST['date_start'];
	        $viewRequest['date_end']=$_POST['date_end'];
	        $viewRequest['length']=$_POST['length'];
	        $view = 'processForm';
	        break;
	        
	     case 'radius':
	     	$viewRequest['type']="radius";
	     	$viewRequest['form'] =$_POST['form'];
	     	$viewRequest['date_start']=$_POST['date_start'];
	        $viewRequest['date_end']=$_POST['date_end'];
	        //var_dump($viewRequest);
	        $view = 'processForm';
	     	break;
	     	
	     case 'failed':
	     	$viewRequest['type']="failed";
	     	$viewRequest['form'] =$_POST['form'];
	     	$viewRequest['date_start']=$_POST['date_start'];
	        $viewRequest['date_end']=$_POST['date_end'];
	        $view = 'processForm';
	     	break;
	     	
	     case 'passed':
	     	$viewRequest['type']="passed";
	     	$viewRequest['form'] =$_POST['form'];
	     	$viewRequest['date_start']=$_POST['date_start'];
	        $viewRequest['date_end']=$_POST['date_end'];
	        $view = 'processForm';
	     	break;
	     	
	     case 'tacacs':
	     	$viewRequest['type']="tacacs";
	     	$viewRequest['form'] =$_POST['form'];
	     	$viewRequest['date_start']=$_POST['date_start'];
	        $viewRequest['date_end']=$_POST['date_end'];
	        $view = 'processForm';
	     	break;
	}
	break;
	
case 'processform2':
	
			$viewRequest['form']=2;
			$viewRequest['type']='proxy';
	        $viewRequest['ip']=$_GET['ip'];
	        $viewRequest['domain']=$_GET['domain'];
	        $viewRequest['date_start']=$_GET['start'];
	        $viewRequest['date_end']=$_GET['end'];
	        $viewRequest['length']=$_GET['length'];
	        $view = 'processForm';
	        break;
	        
case 'drop':
        $view = 'drop';
        break;

case 'dropall':
		$view='dropall';
		break;

default:
		$view = 'mainPage';
}


include_once 'view.inc';


?>